﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Card.Manager
{
    public partial class PaymentMethodManager : BasePage
    {
        protected override void OnInit(EventArgs e)
        {
            this.rptList.ItemCommand += new RepeaterCommandEventHandler(rptList_ItemCommand);
            this.btnQuery.Click += new EventHandler(btnQuery_Click);
            this.btnAdd.Click += new EventHandler(btnAdd_Click);
            base.OnInit(e);
        }

        void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("PaymentMethodEdit.aspx");
        }

        void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "DELETE")
            {
                string[] arr = e.CommandArgument.ToString().Split('|');
                BLL.PaymentMethodManager.Delete(arr[0], arr[1], this.CPassport);
                this.DoQuery();
            }
        }

        void btnQuery_Click(object sender, EventArgs e)
        {
            this.DoQuery();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.DoQuery();
            }
        }

        private void DoQuery()
        {
            this.rptList.DataSource = BLL.PaymentMethodManager.GetListByUserID(this.Passport.UserID,this.txtQuery.Text, this.CPassport);
            this.rptList.DataBind();
        }
    }
}
